<?php
require_once '../sub/init.php';
$currfields = 'sex,grade,openid,subscribe,money';
require_once ZEAI.'m/my_chk_u.php';
$t = (ifint($t,'1-3','1'))?$t:1;
$cook_grade = intval($row['grade']);
$cook_sex   = intval($row['sex']);
if ($submitok == 'ajax_follow_top'){
	if(ifint($id)){
		$db->query("UPDATE ".__TBL_GZ__." SET px=".ADDTIME." WHERE senduid=".$cook_uid." AND id=".$id);
		json_exit(array('flag'=>1));
	}
}elseif($submitok == 'ajax_follow_del'){
	if(ifint($id)){
		$db->query("DELETE FROM ".__TBL_GZ__." WHERE senduid=".$cook_uid." AND id=".$id);
		json_exit(array('flag'=>1));
	}
}elseif($submitok == 'ajax_fans_del'){
	if(!ifint($uid))exit(JSON_ERROR);
	$db->query("DELETE FROM ".__TBL_GZ__." WHERE senduid=".$cook_uid." AND uid=".$uid);
	json_exit(array('flag'=>1));
}elseif($submitok == 'ajax_fans_gz'){
	if(!ifint($uid))exit(JSON_ERROR);
	$db->query("INSERT INTO ".__TBL_GZ__."(uid,senduid,px) VALUES ($uid,$cook_uid,".ADDTIME.")");
	json_exit(array('flag'=>1));
}elseif($submitok == 'ajax_hmd_del'){
	if(ifint($id)){
		$db->query("DELETE FROM ".__TBL_GZ__." WHERE senduid=".$cook_uid." AND id=".$id);
		json_exit(array('flag'=>1));
	}
}
switch ($t) {
	case 1:$t_str='我喜欢';break;
	case 2:$t_str='喜欢我';break;
	case 3:$t_str='黑名单';break;
}
$nodatatips="<div class='nodatatips'><i class='ico'>&#xe608;</i>暂时木有内容呀～～</div>";
function rows_ulist($rows,$p) {
	global $_ZEAI,$t;
	$id      = $rows['id'];
	$uid     = $rows['uid'];
	$nickname = trimhtml(dataIO($rows['nickname'],'out'));
	$sex      = $rows['sex'];
	$grade    = $rows['grade'];
	$photo_s  = $rows['photo_s'];
	$photo_f  = $rows['photo_f'];
	$areatitle= $rows['areatitle'];
	$birthday = $rows['birthday'];
	$heigh    = $rows['heigh'];
	$gzflag   = $rows['gzflag'];
	$flag     = $rows['flag'];
	$photo_ifshow = $rows['photo_ifshow'];
	$birthday_str  = (getage($birthday)<=0)?'':getage($birthday).'岁<b>/</b>';
	$heigh_str     = (empty($heigh))?'':$heigh.'cm<b>/</b>';
	$aARR = explode(' ',$areatitle);$areatitle = $aARR[1].$aARR[2];
	$areatitle_str = (empty($areatitle))?'':$areatitle;
	$photo_s_url=photo_s_out('{"smb":"s","sex":"'.$sex.'","photo_s":"'.$photo_s.'","photo_f":"'.$photo_f.'","photo_ifshow":"'.$photo_ifshow.'","uflag":"'.$flag.'","outkind":"url"}');
	if($flag==-2)$nickname='***';
	$tmpid=$id;
	switch ($t) {
		case 1:
			if($gzflag == 1){
				$btnstr='互相关注';$btncls=' class="ed"';
			}else{
				$btnstr='已关注';$btncls='';
			}
		break;
		case 2:
			if($gzflag == 1){
				$btnstr='互相关注';$btncls=' class="ed"';
			}else{
				$btnstr='<i class="ico">&#xe622;</i> 关注';$btncls=' class="addgz"';
			}
			$tmpid=$uid;
		break;
		case 3:
			$btnstr='取消拉黑';$btncls=' class="hei"';
		break;
	}
	$O  = '<dl>';
	$O .= '<dt><a href="'.a('{"kind":"u","uid":"'.$uid.'"}').'"><img src="'.$photo_s_url.'"></a></dt>';
	$O .= '<dd><h4>'.uicon($sex.$grade).$nickname.'</h4><h6>'.$birthday_str.$heigh_str.$areatitle_str.'</h6></dd>';
	$O .= '<button'.$btncls.' type="button" onClick="gz_del(this,'.$tmpid.')">'.$btnstr.'</button>';
	$O .= '</dl>';
	return $O;
}
$_ZEAI['pagesize'] = 15;
switch ($t) {
	case 1:
		$GZSQL = ",(SELECT COUNT(*) FROM ".__TBL_GZ__." WHERE flag=1 AND senduid=a.uid AND uid=".$cook_uid.") AS gzflag";
		$ZEAI_SQL = "a.senduid=".$cook_uid." AND a.uid=b.id AND a.flag=1";
		$ZEAI_SELECT="SELECT a.id,a.uid,b.nickname,b.sex,b.grade,b.photo_s,b.photo_f,b.areatitle,b.birthday,b.heigh,b.flag,b.photo_ifshow".$GZSQL." FROM ".__TBL_GZ__." a,".__TBL_USER__." b WHERE ".$ZEAI_SQL." ORDER BY a.px DESC,a.id DESC";
	break;
	case 2:
		$GZSQL = ",(SELECT COUNT(*) FROM ".__TBL_GZ__." WHERE flag=1 AND uid=a.senduid AND senduid=".$cook_uid.") AS gzflag";
		$ZEAI_SQL = "a.uid=".$cook_uid." AND a.senduid=b.id AND a.flag=1";
		$ZEAI_SELECT="SELECT a.id,a.senduid AS uid,b.nickname,b.sex,b.grade,b.photo_s,b.photo_f,b.areatitle,b.birthday,b.heigh,b.flag,b.photo_ifshow".$GZSQL." FROM ".__TBL_GZ__." a,".__TBL_USER__." b WHERE ".$ZEAI_SQL." ORDER BY a.px DESC,a.id DESC";
	break;
	case 3:
		$GZSQL = "";
		$ZEAI_SQL = "a.senduid=".$cook_uid." AND a.uid=b.id AND a.flag=-1";
		$ZEAI_SELECT="SELECT a.id,a.uid,b.nickname,b.sex,b.grade,b.photo_s,b.photo_f,b.areatitle,b.birthday,b.heigh,b.flag,b.photo_ifshow".$GZSQL." FROM ".__TBL_GZ__." a,".__TBL_USER__." b WHERE ".$ZEAI_SQL." ORDER BY a.px DESC,a.id DESC";
	break;
}
if($submitok=='ZEAI_list'){exit(Zeai_ajax_list_fn($ZEAI_totalP,$p));}
$rtt=$db->query("SELECT COUNT(*) FROM ".__TBL_GZ__." a,".__TBL_USER__." b WHERE ".$ZEAI_SQL);
$roww = $db->fetch_array($rtt,'num');
$ZEAI_total = $roww[0];
$ZEAI_totalP= ceil($ZEAI_total/$_ZEAI['pagesize']);
$nav='my';?>
<!doctype html><html><head><meta charset="utf-8">
<title>我的-<?php echo $_ZEAI['siteName'];?></title>
<?php echo HEADMETA; ?>
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo HOST;?>/cache/zeaicolor.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script>var t=<?php echo $t;?></script>
<style>
.tabmenu a.ed:after{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
header.bgcolor{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
#backtop a,.btmKefuBtn{color:<?php echo $_ZEAI['mob_mbcolor'];?>;background-color:#fff}
.my_follow{background-color:#fff;padding:0 1.5rem 10rem 1.5rem;margin-top:11rem}
.my_follow dl{border-bottom:#f5f5f5 1px solid;position:relative;height:7rem;box-sizing:border-box}
.my_follow dl dt,.my_follow dl dd{position:absolute;top:1.3rem}
.my_follow dl dt{width:6rem;left:0}
.my_follow dl dt img{width:4.4rem;height:4.4rem;border-radius:2.5rem;object-fit:cover;-webkit-object-fit:cover}
.my_follow dl dd{left:7rem;text-align:left;max-width:-webkit-calc(100% - 15rem)}
.my_follow dl dd h4{font-size:1.4rem}
.my_follow dl dd h6{color:#999;margin-top:.3rem;width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.my_follow dl dd b{font-weight:normal;margin:0 .5rem;color:#ccc;font-size:1.2rem}
.my_follow dl button{width:7rem;display:inline-block;border-radius:.3rem;background-color:#fff;border:#999 1px solid;color:#999;font-size:1.4rem;position:absolute;line-height:2.8rem;right:0;top:1.9rem}
.my_follow dl button.ed{border-color:<?php echo $_ZEAI['mob_mbcolor'];?>;color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.my_follow dl button.addgz{border-color:#037afe;color:#037afe}
.my_follow dl button.hei{border-color:#000;color:#000}
<?php
if ($_ZEAI['m_mb']==2){
	echo '.TRnav_btn i{color:'.$_ZEAI['mob_mbcolor'].'}';
	echo '.tabmenufix{width:60%;max-width:500px;top:1.5rem;margin:auto;left:0;right:0}';
	echo '.my_follow{margin-top:5rem}';
	$mini_class='top_mini4';
}else{
	$mini_title=$t_str;
	echo '.tabmenufix{top:6.7rem}';
	$mini_class='top_mini4 zeaibg bgcolor yunbox';
}
?>
</style>
</head>
<body>
<?php
$mini_href ='zeai.openurl(\'my.php\');';
require_once ZEAI.'m/top_mini.php';
?>
<div class="tabmenu tabmenu3 tabmenufix">
	<a href="my_follow.php?t=1"<?php echo ($t == 1)?' class="ed"':'';?>>我喜欢</a>
	<a href="my_follow.php?t=2"<?php echo ($t == 2)?' class="ed"':'';?>>喜欢我</a>
	<a href="my_follow.php?t=3"<?php echo ($t == 3)?' class="ed"':'';?>>黑名单</a>
</div>
<div class="my_follow" id="ZEAI_list"><?php if($ZEAI_totalP>0){echo Zeai_ajax_list_fn($ZEAI_totalP,$p);}else{echo $nodatatips;}?></div>
<?php if ($ZEAI_total > $_ZEAI['pagesize']){?>
<script>
var ZEAI_totalP = parseInt(<?php echo $ZEAI_totalP; ?>),p=2;
zeaiOnscroll_json={url:'my_follow'+zeai.extname,data:{submitok:'ZEAI_list',ZEAI_totalP:ZEAI_totalP,t:<?php echo $t;?>}};
document.body.onscroll = zeaiOnscroll;
</script>
<div id="backtop"><a href="#top" id="btmTopBtn"><i class="ico">&#xe60c;</i>顶部</a></div>
<?php }?>
<script>
function gz_del(that,id){
	switch (t) {
		case 1:
			ZeaiM.confirmUp({title:'取消关注后，你将无法接收Ta的动态哦',cancel:'我再想想',ok:'取消关注',okfn:function(){
				zeai.ajax({url:'my_follow'+zeai.extname,data:{submitok:'ajax_follow_del',id:id,t:t}},function(e){var rs=zeai.jsoneval(e);if(rs.flag==1){
					that.parentNode.remove();
				}});
			}});
		break;
		case 2:
			if(that.hasClass('addgz')){
				zeai.ajax({url:'my_follow'+zeai.extname,data:{submitok:'ajax_fans_gz',uid:id,t:t}},function(e){var rs=zeai.jsoneval(e);
					if(rs.flag==1){
						that.html('互相关注');that.class('ed');
					}
				});
			}else{
				ZeaiM.confirmUp({title:'取消关注后，你将无法接收Ta的动态哦',cancel:'我再想想',ok:'取消关注',okfn:function(){
					zeai.ajax({url:'my_follow'+zeai.extname,data:{submitok:'ajax_fans_del',uid:id,t:t}},function(e){var rs=zeai.jsoneval(e);
						if(rs.flag==1){
							that.html('<i class="ico">&#xe622;</i> 关注');that.class('addgz');
						}
					});
				}});
			}
		break;
		case 3:
			ZeaiM.confirmUp({title:'确定取消拉黑么',cancel:'我再想想',ok:'确定',okfn:function(){
				zeai.ajax({url:'my_follow'+zeai.extname,data:{submitok:'ajax_hmd_del',id:id,t:t}},function(e){var rs=zeai.jsoneval(e);if(rs.flag==1){
					that.parentNode.remove();
				}});
			}});
		break;
	}
}
</script>
<?php
if($_ZEAI['m_mb']==2){
	require_once ZEAI.'m/bottom2.php';
}else{
	require_once ZEAI.'m/TRnav.php';
	require_once ZEAI.'m/bottom.php';
}
?>